package controller.web;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import dao.AccountTD;
import jakarta.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import pojo.Account;
import util.Jwt;
import util.Result;

import java.util.Map;

@Controller
@CrossOrigin
@ResponseBody
@RequestMapping("/login")
public class LoginController {

    @Autowired
    @Qualifier("accountTD")
    private AccountTD accountTD;
    @PostMapping("/user")
    public Object loginUser(@RequestBody Account account){
        System.out.println(account);
        String id=accountTD.selectPeople(account);
        if(id!=null&&id.equals(account.getId())){
            return Result.success(Jwt.secretKey(account));
        }
        return Result.error("账号或密码错误");
    }
}
